Attribute VB_Name = "modGetUserName"
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Public Function GetCurrentUserName() As String
    Dim sBuffer As String
    Dim size As Long
    Dim ret As Long
    
    size = 32
    sBuffer = String(size, 0)
    
    ret = GetUserName(sBuffer, size)
    GetCurrentUserName = Left(sBuffer, size - 1)
    Debug.Print "|" & GetCurrentUserName & "|"
End Function
